Alternating figure setting

The problem to be solved is to decide if a certain figure has to be set left- or rightjustified. This decision has to made according to the value of the pagecount (left if even, right if odd). That is we are dealing with the wellknown problem to associate a certain part of input text with the number of the page on which it will be set finally.

As pointed out by D.E. Knuth in `The TEXbook' this association is done not before \output routine time. But the problem is not so hard to solve, since in Th. Reid's version there is already a modified \output routine which decides if a certain figure will fit on the current page. As a by-product of this decision one easily gains the information `odd' or `even' for the pagecount of the current page. So our problem reduces to the following simple decision:

   \ifodd\count0 %
      \hbox to \hsize{\hss\copy\figbox}%
      \global\oddpagestrue
    \else% leftsetting
      \hbox to \hsize{\copy\figbox\hss}%
      \global\oddpagesfalse
    \fi% \ifodd\count0